package com.expert.conrtoller;

import com.expert.annotations.RoleAnnotation;
import com.expert.dto.SupplementaryDTO;
import com.expert.enums.RoleLevel;
import com.expert.pojo.ExpertScore;
import com.expert.pojo.ExtractResult;
import com.expert.result.Result;
import com.expert.service.ExtractResultService;
import com.expert.vo.ExtractResultCheckVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Role;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: ExtractResultController
 * @Author: cxs
 * @Date: 2024/03/27 12:56
 * @Description:
 **/
@RestController
@RequestMapping("/extractResult")
@Slf4j
public class ExtractResultController {
    @Autowired
    ExtractResultService extractResultService;
    /**
     * 抽取结果核对
     * @param id 项目id
     * @return
     */
    @GetMapping("/getExtractResultInfo/{id}")
    public Result<List<ExtractResultCheckVo>> getExtractResultCheckInfo(@PathVariable("id") Long id){
        log.info("项目id：{}",id);
        List<ExtractResultCheckVo> checkVoList=this.extractResultService.getExtractResultCheck(id);
        return Result.success(checkVoList);
    }

    /**
     * 重新抽取专家信息
     * @param id 专家id
     * @return result
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PutMapping("/reExtract/{id}")
    public  Result reExtract(@PathVariable("id") Long id){
        log.info("项目id:{}",id);
        this.extractResultService.reExtract(id);
        return Result.success();
    }

    /**
     * 取消抽取专家信息
     * @param id
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PutMapping("/cancelExtractResult/{id}")
    public  Result cancelExtractResult(@PathVariable("id") Long id){
        log.info("项目id:{}",id);
        this.extractResultService.cancelExtractResult(id);
        return Result.success();
    }

    /**
     * 项目
     * @param id
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/checkIsSupplementary/{id}")
    public Result<Boolean> checkIsSupplementary(@PathVariable("id") Long id){
        log.info("项目id:{}",id);
       boolean isSupplementary=this.extractResultService.checkIsSupplementary(id);
       return Result.success(isSupplementary);
    }

    /**
     * 补抽专家
     * @param supplementaryDTO
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PostMapping("/supplementary")
    public Result supplementary(@RequestBody SupplementaryDTO supplementaryDTO){
        log.info("补抽专家");
        this.extractResultService.supplementary(supplementaryDTO);
        return Result.success();
    }

    /**
     * 催促专家
     * @param project
     * @param id
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PostMapping("/urged/{project}/{id}")
    public  Result urged(@PathVariable("project") Long project,@PathVariable("id") Long id){
        log.info("催促专家{}",id);
        this.extractResultService.urged(project,id);
        return Result.success();
    }


    /**
     * 给专家评分
     * @param expertScore
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PostMapping("/scoreExpert")
    public Result scoreExpert(@RequestBody ExpertScore expertScore){
        this.extractResultService.scoreExpert(expertScore);
        return Result.success();
    }
}
